home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Games Collection 1
/
software vault.zip
/
software vault
/
CDR10
/
MAPEDIT.ZIP
/
SAMPGAME
/
MAP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-11
|
4KB
|
165 lines
#include "cyber.h"
#define DUDEY 9*8
#define DUDEX 11*8
int mx=21,my=33;
int cell=1;
char spritename[22];
up()
{
show_sprite(241,145,"uparrowin");
wprintf("Up");
do
{
my--;
make_map();
sprintf(spritename,"up%d",getcell());
putcell(spritename);
show_map();
} while(mousebuttons()==2);
waitup();
show_sprite(241,145,"uparrowout");
}
left()
{
show_sprite(225,161,"leftarrowin");
wprintf("Left");
do
{
mx--;
make_map();
sprintf(spritename,"left%d",getcell());
putcell(spritename);
show_map();
} while(mousebuttons()==2);
waitup();
show_sprite(225,161,"leftarrowout");
}
right()
{
show_sprite(257,161,"rightarrowin");
wprintf("Right");
do
{
mx++;
make_map();
sprintf(spritename,"right%d",getcell());
putcell(spritename);
show_map();
} while(mousebuttons()==2);
waitup();
show_sprite(257,161,"rightarrowout");
}
down()
{
show_sprite(241,177,"downarrowin");
wprintf("Down");
do
{
my++;
make_map();
sprintf(spritename,"down%d",getcell());
putcell(spritename);
show_map();
} while(mousebuttons()==2);
waitup();
show_sprite(241,177,"downarrowout");
}
putsprite(int xs, int ys, int xlen, int ylen, char *sprbuf)
{
int loop;
vwait();
for(loop=0;loop<ylen;loop++)
{
memcpy(scrptr+(ys+loop)*320+xs,sprbuf+loop*xlen,xlen);
}
}
show_sprite(int xs, int ys,char *sprname)
{
int loop;
for(loop=0;loop<db.num_sprites;loop++)
{
if(strcmpi(si[loop].name,sprname)==0)
{
mousecursor(0);
putsprite(xs,ys,si[loop].width,si[loop].height,si[loop].pict);
mousecursor(1);
return;
}
}
}
putcell(char *sprname)
{
int loop,xloop,loop2;
for(loop=0;loop<db.num_sprites;loop++)
{
if(strcmpi(si[loop].name,sprname)==0)
{
for(xloop=0;xloop<si[loop].height;xloop++)
{
for(loop2=0;loop2<si[loop].width;loop2++)
if(*(si[loop].pict+si[loop].width*xloop+loop2))
*(bufptr+(DUDEY+xloop)*320+DUDEX+loop2)=*(si[loop].pict+(xloop*si[loop].width)+loop2);
}
return;
}
}
}
make_map()
{
register char xloop,yloop,loop;
register unsigned int outchar;
for(xloop=0;xloop<21;xloop++)
{
for(yloop=0;yloop<16;yloop++)
{
outchar=mapptr[mx+xloop+(my+yloop)*320];
for(loop=0;loop<8;loop++)
{
memcpy(bufptr+(yloop*8+8+loop)*320+xloop*8+8,csptr+(((outchar/40)*8)+loop)*320+((outchar%40)*8),8);
}
}
}
}
show_map()
{
register char loop;
for(loop=0;loop<16*8;loop++)
memcpy(scrptr+8+(8+loop)*320,bufptr+(8+loop)*320+8,21*8);
}
int getcell()
{
switch(cell)
{
case 1:
cell=2;
return(1);
break;
case 2:
cell=3;
return(2);
break;
case 3:
cell=4;
return(1);
break;
case 4:
cell=1;
return(3);
break;
}
}